<%@page import="java.util.ArrayList"%>
<%@page import="pojo.Favourite"%>
<%@page import="java.util.List"%>
<%@page import="pojo.Customer"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Update</title>
</head>
<body>
<form method="post" action="update">
<input type="text" name="id" value=${customer.id } hidden/>

cname:<input type="text" name="cname" value=${customer.cname }><br>
sal:<input type="text" name="sal" value=${customer.sal }><br>
birth:<input type="date" name="birth" value=<fmt:formatDate value="${customer.birth }" pattern="yyyy-MM-dd" />><br>
sex:
<c:if test="${customer.sex }">
<input type="radio" checked="checked" value=true name="sex"/>男
<input type="radio" name="sex" value="false"/>女<br>
</c:if>
<c:if test="${!customer.sex }">
<input type="radio" value=true name="sex"/>男
<input type="radio" checked="checked"  name="sex" value="false"/>女<br>
</c:if>
<% 
	Customer customer = (Customer) request.getAttribute("customer");
	List<Favourite> favourites = customer.getFavs();
	List<Integer> ids = new ArrayList<Integer>();
	for(Favourite fa:favourites){
		ids.add(fa.getId());
	}

%>
favs:<input type="checkbox"<%if(ids.contains(2)){%>checked="checked"<% } %>  value=2 name="favs"/>篮球
<input type="checkbox" <%if(ids.contains(3)){%>checked="checked"<% } %>  name="favs" value="3"/>足球
<input type="checkbox" <%if(ids.contains(4)){%>checked="checked"<% } %>  name="favs" value="4"/>羽毛球<br>
<input type="submit">
</form>

</body>
</html>